package Matrixmultiply;

import java.math.BigDecimal;
import java.util.Random;

public class MatrixGenerator {
	public static int col = 0;// 确定唯一col使乘法有效
	Random rand = new Random();

	public MatrixGenerator() {
		col = rand.nextInt(500) + 500;
	}

	public double[][] getMatrix1() {
		int row = rand.nextInt(500) + 500;
		System.out.println("create Matrix1:"+"["+row+"]"+"["+col+"]");
		double[][] Matrix1 = new double[row][col];
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				double number = Math.random() * 20 + 1;
				BigDecimal decimal = new BigDecimal(number);
				double num = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
				Matrix1[i][j] = num;
				//System.out.print(Matrix1[i][j] + "\t");
			}
			//System.out.println();
		}
		System.out.println();
		return Matrix1;
	}
 
	public double[][] getMatrix2() {
		int row = rand.nextInt(500) + 500;
		System.out.println("create Matrix2"+"["+col+"]"+"["+row+"]");
		double[][] Matrix2 = new double[col][row];
		for (int i = 0; i < col; i++) {
			for (int j = 0; j < row; j++) {
				double number = Math.random() * 20 + 1;
				BigDecimal decimal = new BigDecimal(number);
				double num = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
				Matrix2[i][j] = num;
				//System.out.print(Matrix2[i][j] + "\t");
			}
			//System.out.println();
		}
		System.out.println();
		return Matrix2;
	}

	public static void main(String[] args) {
		MatrixGenerator a = new MatrixGenerator();
		double[][] Matrix1 = a.getMatrix1();
		double[][] Matrix2 = a.getMatrix2();
	}
}
